# Maintainer: Renato Silva <br.renatosilva@gmail.com>

_realname='purple-hangouts'
pkgbase="mingw-w64-${_realname}-hg"
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}-hg"
pkgver=r287+.574c112aa35c+
pkgrel=1
pkgdesc='Hangouts plugin for libpurple (mingw-w64)'
url='https://bitbucket.org/EionRobb/purple-hangouts'
license=(GPL3+)
arch=('any')
options=(!libtool strip staticlibs)
source=('hg+https://bitbucket.org/EionRobb/purple-hangouts'
        Makefile)
sha256sums=('SKIP'
            '772a5b915291986bd67862de2739106c9234c77d5510236487142cf5d27dfcc6')
conflicts=(${MINGW_PACKAGE_PREFIX}-${_realname})
provides=(${MINGW_PACKAGE_PREFIX}-${_realname})
depends=(${MINGW_PACKAGE_PREFIX}-libpurple
         ${MINGW_PACKAGE_PREFIX}-protobuf-c
         ${MINGW_PACKAGE_PREFIX}-json-glib
         ${MINGW_PACKAGE_PREFIX}-glib2
         ${MINGW_PACKAGE_PREFIX}-zlib
         ${MINGW_PACKAGE_PREFIX}-gettext
         ${MINGW_PACKAGE_PREFIX}-gcc-libs)
makedepends=(${MINGW_PACKAGE_PREFIX}-gcc
             ${MINGW_PACKAGE_PREFIX}-pkg-config
             rsync mercurial)

pkgver() {
    cd "${srcdir}/${_realname}"
    printf "r%s.%s" "$(hg identify -n)" "$(hg identify -i)"
}

prepare() {
    cd "${srcdir}"
    mv Makefile "${_realname}"
}

build() {
    msg2 'Synchronizing build directory'
    rsync --recursive --times "${srcdir}/${_realname}"/* "${srcdir}/${_realname}.build.${CARCH}"
    cd "${srcdir}/${_realname}.build.${CARCH}"
    make
}

package() {
    cd "${srcdir}/${_realname}.build.${CARCH}"
    make DESTDIR="${pkgdir}" install
    install -Dm644 "${srcdir}/${_realname}/gpl3.txt" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/gpl3.txt"
}
